﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace devtm.AutoMapper
{

    public partial class MappingSource
    {

        internal bool ByPass { get; set; }

        public override Mapper Mapper
        {
            get
            {
                return base.Mapper;
            }
            set
            {
                base.Mapper = value;
                if (!ByPass)
                    if (base.Mapper != null
                        && base.Mapper.MappingSource != null
                        && base.Mapper.MappingSource.TypeElement != null)
                    {
                        using (var repository = CustomTypeRepository.Instance(this.Store, false))
                            base.Mapper.MappingSource.TypeElement.RefreshMappers(false, repository);
                    }
            }
        }
    }

}
